﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoderJoe
{
    public class ChildDisposable
        : IDisposable
    {
        public void DoWork()
        {
            if (IsDisposed)
                throw new ObjectDisposedException(GetType().Name);
        }

        #region IDisposable Members

        protected bool IsDisposed { get; private set; }

        protected void Dispose(bool disposing)
        {
            IsDisposed = true;
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        ~ChildDisposable()
        {
            Dispose(false);
        }

        #endregion
    }
}
